<extend name="Shops:layout" />
<block name="content">
<style type="text/css">
#preview{border:1px solid #cccccc; background:#CCC;color:#fff; padding:5px; display:none; position:absolute;}
</style>
<script>
$(document).ready(function(){
    $('.imgPreview').imagePreview();
    <notempty name='shopCatId1'>
    getShopCatListForGoods('{$shopCatId1}','{$shopCatId2}');
    </notempty>
});

function change(val){
	if(val == 'username'){
		$('#query').val('');
		$('#query').attr('placeholder','请输入用户名');
	}else if(val == 'ordersn'){
		$('#query').val('');
		$('#query').attr('placeholder','请输入订单号');
	}else{
		$('#query').val('');
		$('#query').attr('placeholder','请输入用户名/订单号');
	}
}

</script>
    <div class="wst-body"> 
       <div class='wst-page-header'>卖家中心 > 商品管理</div>
	   <div class='wst-page-content' style="margin:10px 0;">
	   
		<div class='wst-tbar-query'>
        <form method="post" style="display:inline-block; ">
		<input type="hidden" value="search_submit" name="search_submit" />
			查询条件：<select onchange="change(this.value);" name="search" id="search">
	        	 <option value="ordersn">订单号</option>
	        	 <option value="username">购买用户名</option>
	        	 <option value="noprize">未中奖</option>
		        <option value="prize">已中奖</option>
            </select>
        <input type="text" placeholder="请输入用户名/订单号" style="width: 200px;" value="" name="query" id="query">
      <button class='wst-btn-query'>查询</button>
        </form>
	<form style="display:inline-block; " method="get" action="">
    <select name="paixu">
	    <option value="time1" {$time1}>按购买时间倒序</option>
	    <option value="time2" {$time2}>按购买时间正序</option>
	    <option value="num1" {$num1}>按购买次数倒序</option>
	    <option value="num2" {$num2}>按购买次数正序</option>
	    <option value="money1" {$money1}>按购买总价倒序</option>
	    <option value="money2" {$money2}>按购买总价正序</option>
    </select>    
    <input type="submit" class="button" name="paixu_submit" value="排序">
    </form>
		
		
		</div>
	   
        <table class='wst-list'>
           <thead>
             <tr>
               <th width='80'>订单号</th>
               <th width="100">商品名称</th>
               <th width="80">购买用户</th>
               <th width="50">购买次数</th>
               <th width="50">购买总价</th>
               <th width="90">购买日期</th>
			  <th width="50">是否中奖</th>
			   <th width="130">状态</th>
               <th width='30'>操作</th>
             </tr>
           </thead>
           <tbody>
            <volist name="data" id="vo" key='i'>
             <tr>
               <td>{$vo['code']}</td>
               <td title="{$vo['shopname']}">{:mb_substr($vo['shopname'],0,10,'utf-8')}</td>
               <td>
               	<font color="#ff600">{$vo['username']}</font>
               </td>
			   <td>{$vo['gonumber']}</td>
			   <td>{$vo['moneycount']}</td>
			   <td>{:date('Y/m/d H:m:s',$vo['time'])}</td>
			   <td>
			   	<if condition="$vo['huode']">
			   		<font color="#ff600">已中奖</font>
				<else/>
					未中奖
				</if>
			   </td>
			   <td>{$vo['status']}</td>
               <td>
              	<a href="{:U('dingdan',array('gid' => $vo['id']))}">[详情]</a>
               </td>
             </tr>
             </volist>
             <tfoot>
             <tr>
                <td colspan='12'>
                <div class="wst-page" style="float:right;padding-bottom:10px;">
						<div id="wst-page-items"></div>
				</div>
                <script>
			   
			    $(document).ready(function(){
				
				$('.yunsetrenqi').click(function(){
					var goodsId = $(this).attr('item');
					if(!goodsId) return;
					$.post(Think.U('Home/Goods/yunsetrenqi'),{gid:goodsId},function(data,textStatus){
						var json = WST.toJson(data);
						alert(json);
					});
				});
					

					
					<if condition="$pageTotal gt 1">
					laypage({
					    cont: 'wst-page-items',
					    pages: {$pageTotal}, //总页数
					    skip: true, //是否开启跳页
					    skin: '#e23e3d',
					    groups: 3, //连续显示分页数
					    curr: function(){ //通过url获取当前页，也可以同上（pages）方式获取
					        var page = location.search.match(/p=(\d+)/);
					        return page ? page[1] : 1;
					    }(), 
					    jump: function(e, first){ //触发分页后的回调
					        if(!first){ //一定要加此判断，否则初始时会无限刷新
					        	var nuewurl = WST.splitURL("p");
					        	var ulist = nuewurl.split("?");
					        	if(ulist.length>1){
					        		location.href = nuewurl+'&p='+e.curr;
					        	}else{
					        		location.href = '?p='+e.curr;
					        	}
					            
					        }
					    }
					});
					
					</if>
					
			    });
				
				</script>
                </td>
             </tr>
             </tfoot>
           </tbody>
        </table>
        <div class='wst-tbar-group'>
           {$page}
        </div>
        </div>
    </div>
</block> 